import React, { Component } from "react";
import  img from  "../img/3.jpg";

export default class Page3 extends Component {
  constructor() {
    super();
    this.state = {
      flag: false,
      myStyle: {
        color: "red",
      },
    };
  }
  change = () => {
    this.setState({
      flag: !this.state.flag,
      myStyle: { color: this.state.myStyle.color === "red" ? "green" : "red" },
    });
  };

  render() {
    return (
      <div>
        <h3>行内样式</h3>
        <button
          onClick={() => {
            this.change();
          }}
        >
          样式切换
        </button>
        <div style={{ display: this.state.flag ? "block" : "none" }}>提示</div>
        <div style={this.state.myStyle}> 提示2</div>

        <img
          src="https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"
          alt="图片"
        />
        <img alt="本地图片" src="../img/3.jpg"/>
        <img alt="本地图片" src={img}/>
      </div>
    );
  }
}
